<template>
	<om-page :title="pageTitle" v-show="showdata">
		<view class="workhour-cache-info-user padding-left padding-top-xs om_hd_fix" style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
			<view class="">
				<image class=" workhour-cache-info-user-head" :src="'/'+om.getAvatar(sSexCode)" mode="aspectFit">
			</view>
			<view class="margin-left om-font-size workhour-cache-info-user-name">
				{{data.userName + ' / ' + data.posName}}
			</view>
		</view>
		<view class="workhour-cache-info-user"  v-if="true"></view>
		<view class="page__bd">
			<view class="tui-flex align-center">
				<uni-collapse :accordion="true">
					<uni-collapse-other-item  title="出勤班次" :unit="'次'" color="#333333"  :showLength="true" :text="data.clazzNum+''" >
						<view class="margin-left">
							<view class="padding om-font-size border-buttom">
								<view class="" v-for="(e,index) of data.clazzNums" :key="index">
									{{e.clazzName + (e.startStdA?'('+ e.startStdA + '-' + e.endStdA+"," :'') + (e.startStdB? e.startStdB + '-' + e.endStdB + ')':'') + e.num+'次'}}
								</view>
							</view>
						</view>
						<view class="margin-left" v-for="(item,index) of data.clazzNumRecords" :key="'clazzNumRecords'+index">
							<view class="padding om-font-size border-buttom">
								{{item.date+'('+item.week+')'+'\xa0\xa0\xa0\xa0\xa0\xa0\xa0'+item.clazzName }}
							</view>
						</view>
					</uni-collapse-other-item>
					<uni-collapse-other-item  title="应出勤" :unit="'天'" :showArrow="false"  color="#333333" :showLength="true" :text="data.monthAttendStdDays+''">
					</uni-collapse-other-item>
					<uni-collapse-other-item  title="计酬天数" :unit="'天'" :showArrow="false"  color="#333333" :showLength="true" :text="(data.salaryDays || 0)+''">
					</uni-collapse-other-item>
					<uni-collapse-other-item  title="出勤" :unit="'天'"  color="#333333" :showLength="true" :text="data.monthAttendDays+''">
						<view class="margin-left">
							<view class="padding om-font-size border-buttom">
								{{'应出勤' + (data.monthAttendStdDays || 0 ) +'天'+'，'+'实际出勤'+ (data.monthAttendDays|| 0 )+'天' +'；'+'应出勤' + (data.monthAllAttendStdHours || 0 ) +'小时'+'，'+'实际出勤'+ (data.monthAttendHours|| 0 )+'小时'}}
							</view>
						</view>
						<view class="margin-left" v-for="(item,index) of data.monthAttendHoursRecords" :key="'monthAttendHoursRecords'+index">
							<view class="padding om-font-size border-buttom">
								{{item.date+'('+item.week+')' + '\xa0\xa0\xa0' + '出勤'+ item.hours +'小时'+ '，' +'计酬' + item.salaryHours+'小时'}}
							</view>
						</view>
					</uni-collapse-other-item>
					<uni-collapse-other-item  title="加班" :unit="''"  :color="(data.addFormTimes != data.addTimes)?'red':'#333333'" :showLength="true" :text="data.monthTotalAddHours+'小时'+((data.addFormTimes != data.addTimes)?'(异常'+(data.addFormTimes-data.addTimes)+'次' + ')':'')">
						<view class="margin-left">
							<view class="padding om-font-size border-buttom">
								{{'申请' + (data.addFormTimes || 0)+'次'+'，'+'实际'+ (data.addTimes || 0)+'次' + getAddCateMap}}
							</view>
						</view>
						<view class="margin-left">
							<view class="om-font-size border-buttom collapse-item-info">
								<uni-collapse>
									<uni-collapse-other-item v-if="data.normalAddMap" :title="'正常班加班'"  :color="'#333333'" :unit="'小时'"  :showLength="true" :text="data.normalAddMap.hours+''">
										<view class="margin-left" v-for="(item,index) of hasSubList('normalAddMap')" :key="'normalAddMap'+index">
											<view class="om-font-size border-buttom collapse-item-info">
												<uni-collapse>
													<uni-collapse-other-item :titleColor="(item.hours?'':'red')" :color="'#333333'" :title="item.date+'('+item.week+')'" :unit="item.hours?'小时':''" :open="false" :showLength="true" :text="(item.hours?item.hours:'')+''">
														<view class="margin-left" v-for="(subItem,i) in item.subList" :key="'addSubItem'+ i ">
															<view class="padding om-font-size border-buttom collapse-item-info">
																<view v-if="item.hours">
																	<view class="">
																		{{subItem.stdStart +'-'+ subItem.stdEnd + '申请加班'+subItem.applyHours+'小时'+(subItem.start && subItem.end?'，':'')}}
																	</view>
																	<view class="" v-if="subItem.start && subItem.end">
																		{{subItem.start +'-'+ subItem.end +'实际加班'+subItem.hours+'小时'+(subItem.salaryHandleName?'，':'')}}
																	</view>
																	<view class="">
																		{{subItem.salaryHandleName}}
																	</view>
																</view>
																<view v-else > 
																	{{'申请加班时间' + subItem.stdStart +'-' + subItem.stdEnd}}
																</view>
																<view v-if="!data.repairAddForm" class="">
																	<view class="collapse-item-info-button">
																		<view  class="padding-left" @click="itemClick('add',subItem)">
																			去查看
																		</view>
																	</view>
																</view>
																<view v-else class="">
																	<view class="collapse-item-info-button"  v-if="(!subItem.repairStart && !subItem.repairEnd)">
																			<text class="padding-left" @click="itemClick('add',subItem)">
																				去查看
																			</text>
																	</view>
																	<view class="collapse-item-info-button"  v-else-if="((subItem.repairStart || subItem.repairEnd) && (!subItem.startFileCode && !subItem.endFileCode))">
																		<text class="padding-left" @click="itemClick('addRepair',subItem,item.date)">
																			去处理
																		</text>
																	</view>
																	<view class="collapse-item-info-button"  v-else>
																		<text class="padding-left" @click="itemClick('addRepaired',subItem)">
																			去查看
																		</text>
																	</view>
																	</view>
																</view>
														</view>
													</uni-collapse-other-item>
												</uni-collapse>
											</view>
										</view>
									</uni-collapse-other-item>
									<uni-collapse-other-item v-if="data.sunAddMap"  :title="'休息日加班'" :color="'#333333'" :unit="'小时'"  :showLength="true" :text="data.sunAddMap.hours+''">
										<view class="margin-left" v-for="(item,index) of hasSubList('sunAddMap')" :key="'sunAddMap'+index">
											<view class="om-font-size border-buttom collapse-item-info">
												<uni-collapse>
													<uni-collapse-other-item :color="'#333333'"  :titleColor="(item.hours?'':'red')" :title="item.date+'('+item.week+')'" :unit="item.hours?'小时':''" :open="false" :showLength="true" :text="(item.hours?item.hours:'')+''">
														<view class="margin-left" v-for="(subItem,i) in item.subList" :key="'addSubItem'+ i ">
															<view class="padding om-font-size border-buttom collapse-item-info">
																<view v-if="item.hours">
																	<view class="">
																		{{subItem.stdStart +'-'+ subItem.stdEnd + '申请加班'+subItem.applyHours+'小时'+(subItem.start && subItem.end?'，':'')}}
																	</view>
																	<view class="" v-if="subItem.start && subItem.end">
																		{{subItem.start +'-'+ subItem.end +'实际加班'+subItem.hours+'小时'+(subItem.salaryHandleName?'，':'')}}
																	</view>
																	<view class="">
																		{{subItem.salaryHandleName}}
																	</view>
																</view>
																<view v-else> 
																	{{'申请加班时间' + subItem.stdStart +'-' + subItem.stdEnd}}
																</view>
																<view v-if="!data.repairAddForm" class="">
																	<view class="collapse-item-info-button">
																		<view  class="padding-left" @click="itemClick('add',subItem)">
																			去查看
																		</view>
																	</view>
																</view>
																<view v-else class="">
																	<view class="collapse-item-info-button"  v-if="(!subItem.repairStart && !subItem.repairEnd)">
																			<text class="padding-left" @click="itemClick('add',subItem)">
																				去查看
																			</text>
																	</view>
																	<view class="collapse-item-info-button"  v-else-if="((subItem.repairStart || subItem.repairEnd) && (!subItem.startFileCode && !subItem.endFileCode))">
																		<text class="padding-left" @click="itemClick('addRepair',subItem,item.date)">
																			去处理
																		</text>
																	</view>
																	<view class="collapse-item-info-button"  v-else>
																		<text class="padding-left" @click="itemClick('addRepaired',subItem)">
																			去查看
																		</text>
																	</view>
																	</view>
																</view>
														</view>
													</uni-collapse-other-item>
												</uni-collapse>
											</view>
										</view>
									</uni-collapse-other-item>
									<uni-collapse-other-item v-if="data.weekendAddMap" :title="'法定假日加班'" :color="'#333333'" :unit="'小时'"  :showLength="true" :text="data.weekendAddMap.hours+''">
										<view class="margin-left" v-for="(item,index) of hasSubList('weekendAddMap')" :key="'weekendAddMap'+index">
											<view class="om-font-size border-buttom collapse-item-info">
												<uni-collapse>
													<uni-collapse-other-item :color="'#333333'" :title="item.date+'('+item.week+')'" :unit="item.hours?'小时':''" :open="false" :showLength="true" :text="(item.hours?item.hours:'')+''">
														<view class="margin-left" v-for="(subItem,i) in item.subList" :key="'addSubItem'+ i ">
															<view class="padding om-font-size border-buttom collapse-item-info">
																<view v-if="item.hours">
																	<view class="">
																		{{subItem.stdStart +'-'+ subItem.stdEnd + '申请加班'+subItem.applyHours+'小时'+(subItem.start && subItem.end?'，':'')}}
																	</view>
																	<view class="" v-if="subItem.start && subItem.end">
																		{{subItem.start +'-'+ subItem.end +'实际加班'+subItem.hours+'小时'+(subItem.salaryHandleName?'，':'')}}
																	</view>
																	<view class="">
																		{{subItem.salaryHandleName}}
																	</view>
																</view>
																<view v-else> 
																	{{'申请加班时间' + subItem.stdStart +'-' + subItem.stdEnd}}
																</view>
																<view v-if="!data.repairAddForm" class="">
																	<view class="collapse-item-info-button">
																		<view  class="padding-left" @click="itemClick('add',subItem)">
																			去查看
																		</view>
																	</view>
																</view>
																<view v-else class="">
																	<view class="collapse-item-info-button"  v-if="(!subItem.repairStart && !subItem.repairEnd)">
																			<text class="padding-left" @click="itemClick('add',subItem)">
																				去查看
																			</text>
																	</view>
																	<view class="collapse-item-info-button"  v-else-if="((subItem.repairStart || subItem.repairEnd) && (!subItem.startFileCode && !subItem.endFileCode))">
																		<text class="padding-left" @click="itemClick('addRepair',subItem,item.date)">
																			去处理
																		</text>
																	</view>
																	<view class="collapse-item-info-button"  v-else>
																		<text class="padding-left" @click="itemClick('addRepaired',subItem)">
																			去查看
																		</text>
																	</view>
																	</view>
																</view>
														</view>
													</uni-collapse-other-item>
												</uni-collapse>
											</view>
										</view>
									</uni-collapse-other-item>
								</uni-collapse>
							</view>
						</view>
					</uni-collapse-other-item>
					<uni-collapse-other-item v-if="data.turnOnAskleave"  :title="'请假'" :unit="'小时'" :color="'#333333'" :showLength="true" :text="data.totalLeaveHours +''" >
						<view class="margin-left" v-show="getLeaveCateHours">
							<view class="padding om-font-size border-buttom">
								{{getLeaveCateHours}}
							</view>
						</view>
						<view class="margin-left" v-for="(item,index) of data.totalLeaveHoursRecords" :key="'totalLeaveHoursRecords'+index">
							<view class="padding om-font-size border-buttom collapse-item-info">
								<view>
									<view>
										{{'开始时间:' + item.startDate}}
									</view>
									<view>
										{{'结束时间:' + item.endDate}}
									</view>
									<view>
										{{ item.catName + '('+(item.hours?item.hours + '小时' : '未统计') + ')'}}
									</view>
								</view>
								<view class="collapse-item-info-button">
									<text class="padding-left" @click="itemClick('leave',item)">
										去查看
									</text>
								</view>
							</view>
						</view>
					</uni-collapse-other-item>
					<uni-collapse-other-item  title="未考勤" :unit="'次'" :color="data.absentTimes>0?'red':'#333333'" :showLength="true" :text="data.absentTimes+''" >
						<view class="margin-left">
							<view class="padding om-font-size border-buttom">
								{{'未考勤'+ data.absentHours+'小时'}}
							</view>
						</view>
						<view class="margin-left" v-for="(item,index) of data.absentHoursRecords" :key="'absentHoursRecords'+index">
							<view class="om-font-size border-buttom collapse-item-info">
								<uni-collapse>
									<uni-collapse-other-item :unit="'小时'" :title="item.date+'('+item.week+')'" :color="'#333333'"  :showLength="true" :text='item.hours+""'>
										<view class="margin-left" v-if="item.exStartAMsg">
											<view class="padding om-font-size border-buttom collapse-item-info">
												<view>
													{{'A上'+ '('+item.startTimeStdA+')'}}
												</view>
												<view v-if="item.exStartAMsg">
													{{item.exStartAMsg}}
												</view>
												<view class="collapse-item-info-button">
													<text v-if="!item.exStartAFileCode" class="padding-left" @click="itemClick('absentHours',item,item.startTimeStdA,'AStart')">
														去处理
													</text>
													<text v-else class="padding-left" @click="itemClick('lookAbsentHours',item,item.exStartAFileCode,item.exStartAFormCode)">
														去查看
													</text>
												</view>
											</view>
										</view>
										<view class="margin-left" v-if="item.exEndAMsg">
											<view class="padding om-font-size border-buttom collapse-item-info">
												<view>
													{{'A下'+ '('+item.endTimeStdA+')'}}
												</view>
												<view v-if="item.exEndAMsg">
													{{item.exEndAMsg}}
												</view>
												<view class="collapse-item-info-button">
													<text v-if="!item.exEndAFileCode" class="padding-left" @click="itemClick('absentHours',item,item.endTimeStdA,'AEnd')">
														去处理
													</text>
													<text v-else class="padding-left" @click="itemClick('lookAbsentHours',item,item.exEndAFileCode,item.exEndAFormCode)">
														去查看
													</text>
												</view>
											</view>
										</view>
										<view class="margin-left" v-if="item.exStartBMsg">
											<view class="padding om-font-size border-buttom collapse-item-info">
												<view>
													{{'B上'+ '('+item.startTimeStdB+')'}}
												</view>
												<view v-if="item.exStartBMsg">
													{{item.exStartBMsg}}
												</view>
												<view class="collapse-item-info-button">
													<text v-if="!item.exStartBFileCode" class="padding-left" @click="itemClick('absentHours',item,item.startTimeStdB,'BStart')">
														去处理
													</text>
													<text v-else class="padding-left" @click="itemClick('lookAbsentHours',item,item.exStartBFileCode,item.exStartBFormCode)">
														去查看
													</text>
												</view>
											</view>
										</view>
										<view class="margin-left" v-if="item.exEndBMsg">
											<view class="padding om-font-size border-buttom collapse-item-info">
												<view>
													{{'B下'+ '('+item.endTimeStdB+')'}}
												</view>
												<view v-if="item.exEndBMsg">
													{{item.exEndBMsg}}
												</view>
												<view class="collapse-item-info-button">
													<text v-if="!item.exEndBFileCode" class="padding-left" @click="itemClick('absentHours',item,item.endTimeStdB,'BEnd')">
														去处理
													</text>
													<text v-else class="padding-left" @click="itemClick('lookAbsentHours',item,item.exEndBFileCode,item.exEndBFormCode)">
														去查看
													</text>
												</view>
											</view>
										</view>
									</uni-collapse-other-item>
								</uni-collapse>
							</view>
						</view>
					</uni-collapse-other-item>
					<uni-collapse-other-item  title="迟到" :unit="'次'" :color="data.lateMinutesRecords.length>0?'red':'#333333'" :showLength="true" :text="data.lateTimes +''" >
						<view class="margin-left">
							<view class="padding om-font-size border-buttom">
								{{'迟到'+ data.lateMinutes+'分钟'}}
							</view>
						</view>
						<view class="margin-left" v-for="(item,index) of data.lateMinutesRecords" :key="'lateMinutesRecords'+index">
							<view class="om-font-size border-buttom collapse-item-info">
								<uni-collapse>
									<uni-collapse-other-item :unit="'分钟'" :title="item.date+'('+item.week+')'" :color="'#333333'" :showLength="true"  :text="(item.minutes||item.salaryMinutes) +''">
										<view class="margin-left" v-for="(subItem,subIndex) of item.subList" :key="'lateMinutesRecords'+subIndex">
											<view class="padding om-font-size border-buttom">
												{{subItem.node+'('+subItem.minutes+'分钟)'}}
											</view>
										</view>
									</uni-collapse-other-item>
								</uni-collapse>
							</view>
						</view>
					</uni-collapse-other-item>
					<uni-collapse-other-item  title="早退" :unit="'次'" :color="data.earlyMinutesRecords.length>0?'red':'#333333'" :showLength="true" :text=" data.earlyTimes+''" >
						<view class="margin-left">
							<view class="padding om-font-size border-buttom">
								{{'早退'+ data.earlyMinutes+'分钟'}}
							</view>
						</view>
						<view class="margin-left" v-for="(item,index) of data.earlyMinutesRecords" :key="'earlyMinutesRecords'+index">
							<view class="om-font-size border-buttom collapse-item-info">
								<uni-collapse>
									<uni-collapse-other-item :unit="'分钟'" :title="item.date+'('+item.week+')'" :color="'#333333'" :showLength="true"  :text="(item.minutes||item.salaryMinutes) +''">
										<view class="margin-left" v-for="(subItem,subIndex) of item.subList" :key="'earlyMinutesRecords'+subIndex">
											<view class="padding om-font-size border-buttom">
												{{subItem.node+'('+subItem.minutes+'分钟)'}}
											</view>
										</view>
									</uni-collapse-other-item>
								</uni-collapse>
							</view>
						</view>
					</uni-collapse-other-item>
					<uni-collapse-other-item v-if="data.turnOnOuter"  title="出差" :unit="'次'" :color="'#333333'" :showLength="true" :text="data.outerTimes+''" >
						<view class="margin-left">
							<view class="padding om-font-size border-buttom">
								{{'出差'+ data.outerHours+'小时'}}
							</view>
						</view>
						<view class="margin-left" v-for="(item,index) of data.outerHoursRecords" :key="'outerHoursRecords'+index">
							<view class="padding om-font-size border-buttom collapse-item-info">
								<view>
									<view>
										{{'开始时间:' + item.startDate}}
									</view>
									<view>
										{{'结束时间:' + item.endDate}}
									</view>
									<view>
										{{ item.hours?item.hours + '小时' : '未统计'}}
									</view>
								</view>
								<view class="collapse-item-info-button">
									<text class="padding-left " @click="itemClick('outer',item)">
										去查看
									</text>
								</view>
							</view>
						</view>
					</uni-collapse-other-item>
					<uni-collapse-other-item v-if="data.turnOnGouout"  title="外出" :unit="'次'" :color="'#333333'" :showLength="true" :text="(data.gooutTimes?data.gooutTimes:'0')+''" >
						<view class="margin-left">
							<view class="padding om-font-size border-buttom">
								{{'外出'+ data.gooutHours+'小时'}}
							</view>
						</view>
						<view class="margin-left" v-for="(item,index) of data.gooutHoursRecords" :key="'gooutHoursRecords'+index">
							<view class="padding om-font-size border-buttom collapse-item-info">
								<view>
									<view>
										{{'开始时间:' + item.startDate}}
									</view>
									<view>
										{{'结束时间:' + item.endDate}}
									</view>
									<view>
										{{ item.hours?item.hours + '小时' : '未统计'}}
									</view>
								</view>
								<view class="collapse-item-info-button">
									<text class="padding-left " @click="itemClick('outer',item)">
										去查看
									</text>
								</view>
							</view>
						</view>
					</uni-collapse-other-item>
					<uni-collapse-other-item v-if="data.turnOnRepair"  title="补签" :color="'#333333'" :showLength="true" :text="data.repairTimesRecords.length +''" >
						<view class="margin-left" v-for="(item,index) of data.repairTimesRecords" :key="'repairTimesRecords'+index">
							<view class="om-font-size border-buttom collapse-item-info">
								<uni-collapse>
									<view class="padding om-font-size border-buttom collapse-item-info">
										<view>
											{{item.date + '('+item.node + ')'}}
										</view>
										<view class="collapse-item-info-button">
											<text class="padding-left" @click="itemClick('repair',item)">
												去查看
											</text>
										</view>
									</view>
								</uni-collapse>
							</view>
						</view>
					</uni-collapse-other-item>
					<uni-collapse-other-item  v-if="isShow || data.signature || data.systemFlag" title="本人签名" :unit="''" :color="data.signature || data.systemFlag?'#333333':'red'" :showLength="true" :text="data.signature || data.systemFlag?'已签名':'未签名'" >						
						<view class="margin-left" v-if="data.tipConfirmTime">
							<view class="padding om-font-size border-buttom">
								{{data.tipConfirmTime?('个人确认开始日期:'+ data.tipConfirmTime):'' }}
							</view>
						</view>
						<view class="margin-left" v-if="data.stopUserConfirmTime">
							<view class="padding om-font-size border-buttom">
								{{ data.stopUserConfirmTime?('个人确认截止时间:'+data.stopUserConfirmTime):''}}
							</view> 
						</view>
						<view class="margin-left" v-if="data.systemFlag">
							<view class="padding om-font-size border-buttom">
								{{ '系统确认:'+'√'}}
							</view> 
						</view>
						<view v-if="!data.signature && !data.systemFlag" class="margin-left" @click="toSignature">
							<view v-if="!isSign" class="padding om-font-size border-buttom" style="display: flex;justify-content: space-between;">
								<text class="">
									{{'去签名'}}
								</text>
								<uni-icons :size="20" class="uni-icon-wrapper" color="#bbb" type="arrowright" />
							</view>
							<view v-else class="tui-col-7" style="width: 100%;display: flex;justify-content: center;"   @tap.stop="isComfir?imageView(image):toSignature()">
								<image :src="captchaSrc(image)"   id="signImage" mode="widthFix" :style="{ height:imgHeight+'px',width:imgWidth+'px',border:'2px solid #ddd'}"></image>
							</view>
						</view>
						<view  v-if="data.signature" class="tui-left" style=" display:flex;justify-content: center;" @tap="imageView(data.signature)">
							<image :src="data.signature" @load="changeImage" id="showSign" mode="widthFix" :style="{ height:imgHeight+'px',width:imgWidth+'px',border:'2px solid #ddd'}"></image>
						</view>
					</uni-collapse-other-item>
				</uni-collapse>
			</view>
		</view>
		<om-white-space></om-white-space>
		<om-white-space></om-white-space>
		<om-white-space></om-white-space>
		<om-white-space></om-white-space>
		<om-white-space></om-white-space>
		<om-white-space></om-white-space>
		<om-white-space></om-white-space>
		<om-button v-if="isShow" :buttons="confirmBtn" @btnChange="btnClick"></om-button>
		<om-white-space></om-white-space>
		<uni-popup  id="popup" ref="popup" :type="'center'">
			<view class="popup-cotent padding">
				<view class="margin popup-tip">
					请选择表单
				</view>
				<view  class="popup-item padding"  v-for="(item,index) of popupList" :key="index" @click="toShow(item,formCode)">
					<text v-if="type=='leave'">
						{{'表单编码:'+ item.code}}
					</text>
					<text v-else-if="type== 'add'" >
						{{'表单编码:'+item.fileCode +'\xa0\xa0\xa0'+ item.start + '-' +item.end}}
					</text>
					<text v-else-if="type== 'absentHours'">
						{{item.title}}
					</text>
					<uni-icons :size="20" class="uni-icon-wrapper" color="#bbb" type="arrowright" />
				</view>
				<view class="margin flex justify-end" @click="cancel">
					<text class="margin-top" style="color: #5697F4;">
						取消
					</text>
				</view>
			</view>
		</uni-popup>
	</om-page>
</template>

<script>
	import {
		mapState
	} from 'pinia';
	import {
		useLoginUserStore
	} from '@/stores/login-user.js';
	import {isEnglish,filterNumbers} from '@/static/js/common.js';
	export default {
		provide(){
			return {
				info:this
			}
		},
		computed: {
			...mapState(useLoginUserStore, ['hasLogin', 'forcedLogin', 'userName','userId',"avatar","sexCode"
			// #ifdef MP-WEIXIN
			,'db','openid','orgCode'
			// #endif
			]
			),
			isRed(){
				// let _that = this
				// if(_that.data.monthTotalAddHoursRecords.length){
				// 	for(let item of _that.data.monthTotalAddHoursRecords){
				// 		let red = item.subList.some((subItem,index)=> (subItem.repairStart || subItem.repairEnd))
				// 		return red
				// 	}
				// }
			},
			getClazzNums(){
				let str = this.data.clazzNums.map(e=>{
					return e.clazzName + e.num+'次' + '('+ (e.startStdA?e.startStdA:e.startStdB) + '-' + e.endStdB + ')'
				}).join('，')
				return str
			},
			getLeaveCateHours(){
				let _that = this
				let str = ''
				let keys = []
				let values = []
				if(_that.data.leaveCateHours){
					keys = Object.keys(_that.data.leaveCateHours)
					values = Object.values(_that.data.leaveCateHours)
					let newkeys = keys.filter((item,index,array) => values[index] > 0)
					let newValues = values.filter((item,index,array) => values[index] > 0)
					str = newkeys.map((e,index)=> newkeys[index] + newValues[index] + '小时').join('，')
					return str
				}else{
					return ''
				}
			},
			getCateMap(){
				return function(arr){
					let str = ''
					let keys = []
					let values = []
					if(arr){
						keys = Object.keys(arr)
						values = Object.values(arr)
						str = keys.map((e,index)=> str = keys[index] + values[index]+'小时').join('，')
						return str
					}else{
						return ''
					}
				}
			},
			getAddCateMap(){
				let _that = this
				let keys1,keys2,keys3 = []
				let str = ''
				keys1 = Object.keys(_that.data.normalAddMap?(_that.data.normalAddMap.cateMap):{})
				keys2 = Object.keys(_that.data.sunAddMap?(_that.data.sunAddMap.cateMap):{})
				keys3 = Object.keys(_that.data.weekendAddMap?(_that.data.weekendAddMap.cateMap):{}) 
				let arr = keys1.concat(keys2,keys3);
				let keys = [...new Set(arr)]; 
				str = keys.map(e => {
					return (e + (Number((_that.data.normalAddMap? (_that.data.normalAddMap.cateMap[e]?Number(_that.data.normalAddMap.cateMap[e]).toFixed(2) : 0) : 0)) + Number((_that.data.sunAddMap? (_that.data.sunAddMap.cateMap[e]?Number(_that.data.sunAddMap.cateMap[e]).toFixed(2):0) : 0)) + Number((_that.data.weekendAddMap? (_that.data.weekendAddMap.cateMap[e]?Number(_that.data.weekendAddMap.cateMap[e]).toFixed(2):0) : 0))))+'小时'}).join(',')
				return '('+str+')'
			}
		},
		data() {
			return {
				bottomTips:'请在框中书写，签名仅限于业务信息接收确认',
				showdata:false,
				sSexCode:"",
				sUserId:'',
				id:'',
				absentDate:"",
				absentTime:'',
				attendYear: "",       
				attendMonth: "",
				pageTitle:"",
				confirmBtn: [{
					text: "确认",
					bgcolor: "#5697F4"
				}],
				clickItem:'',
				showAll: false,
				type:"",
				isComfir: false,
				storageKey: "signature-key",
				image: "",
				imgHeight: '',
				isSign:false,
				imgWidth: '',
				isSmall: false,
				popupList:[],
				formCode:'',
				hasConfirmed:false,
				repairAbsentForms:[],
				isShow:false,
				data: {
					turnOnAskleave:true,
					turnOnOuter:true,
					turnOnRepair:true,
					turnOnGouout:true,
					absentHours: 0, //   				   未考勤工时
					absentHoursRecords: []	, //   		   未考勤工时展开
					absentTimes:0		, //   			   未考勤次数
					addFormTimes:0		, //   			   申请加班次数
					addTimes:0			, //   			   实际加班次数
					clazzNum:0, //                         出勤班次
					clazzMsg:"",		//					每种班次出勤次数提示
					clazzNums:[],
					clazzNumRecords:[] ,// 					出勤班次展开
					earlyMinutes:0		, //   			   当月合计早退分钟
					earlyMinutesRecords: []  	, //   	   当月合计早退分钟展开
					earlyTimes:0			, //   			   早退次数
					lateMinutes:0			, //   		   当月合计迟到分钟
					lateMinutesRecords: []		, //   	   当月合计迟到分钟展开
					lateTimes:0				, //   		   迟到次数
					leaveTimes:0			, //   			   请假次数
					monthAllAttendStdHours:0	, //   		   全月应出勤工时
					monthAttendDays:0		, //   		   月份合计出勤天数
					monthAttendHours:0		, //   		   实际出勤工时
					monthAttendHoursRecords: []	, //   	   出勤工时展开
					monthAttendStdDays:0		, //   		   月份应出勤天数
					monthTotalAddHours:0		, //   		   当月合计加班工时
					normalAddMap:{
						monthTotalAddHoursRecords: []	, //      当月合计加班工时展开
						cateMap:[]
					},
					sunAddMap:{
						monthTotalAddHoursRecords: []	, //      当月合计加班工时展开
						cateMap:[]
					},
					weekendAddMap:{
						monthTotalAddHoursRecords: []	, //      当月合计加班工时展开
						cateMap:[]
					},
					outerHours:0		, //   				   公出工时
					outerHoursRecords: []	, //   		   公出工时展开
					outerTimes:0		, //   				   公出次数
					gooutHours:0,
					gooutTimes:0,
					gooutHoursRecords:[],
					posName:''			, //   			   岗位/机构
					repairTimes:0			, //   		   补签考勤次数
					repairTimesRecords: []		, //   	   补签考勤次数展开
					totalLeaveHours:null		, //   		   合计请假工时
					totalLeaveHoursRecords: []		, //      合计请假工时展开
					userName:''               , //           出勤人
					ymDate:null   				 ,//   	   年月		
					startDate:'',
					endDate:'',
				}
			}
		},
		methods: {
			getAccessToken(){
				let _that = this
				_that.om.getBaiduToken()
			},
			hasSubList(options){
				if(this.data[options] && this.data[options].monthTotalAddHoursRecords){
					return this.data[options].monthTotalAddHoursRecords
				}else{
					return []
				}
			},
			lookSelf(){
				this.getAttendMonth(this.userId)
				uni.removeStorage({
					key:"workhour"
				})
			},
			cancel(){
				this.$refs.popup.close()
			},
			changeImage(){
				let _that = this
				_that.$nextTick(function(){
					let signImage = uni.createSelectorQuery().select("#showSign")
					signImage.boundingClientRect((data) => {
						if (!_that.isSmall) {
							_that.imgHeight = (data.height) / 3
							_that.imgWidth = (data.width) / 3
							_that.isSmall = !_that.isSmall
						}
					}).exec()
				})
			}, 
			imageView(url){
				uni.setStorage({
					key:"image-cache",
					data:url
				})
				uni.navigateTo({
					url:'../../public/img-view/img-view'
				})
			},
			btnClick() {
				let _that = this
				if (!_that.image) {
					if(isEnglish(_that.userName)){
						uni.navigateTo({
							url: "../../public/signature/signature?goToOld="+true
						})
					}else{
						let signName = filterNumbers(_that.userName)
						uni.navigateTo({
							url: "../../public/signature/signature?bottomTips=" + _that.bottomTips + '&userName=' + signName
						})
					}
					return
				}
				_that.om.request(
					"attendMonth/doWorkhourConfirm", {
						signature: this.image,
						id:_that.id
					},
					"post"
				).then(res => {
					if (!res.succeed){
						_that.om.toast(res.msg, 3000)
					} else {
						_that.om.toast("确认成功")
						_that.isShow = false
						_that.hasConfirmed = true
						_that.tips = ''
						_that.isComfir = true
					}
					this.getAttendMonth()
				})
			},
			captchaSrc(image){
				return image.replace(/[\r\n]/g, "");
			},
			showImage() {
				let _that = this
				try {
					const value = uni.getStorageSync(_that.storageKey);
					if (value) {
						_that.image = value
						_that.$nextTick(() => {
							let signImage = uni.createSelectorQuery().select("#signImage")
							signImage.boundingClientRect((data) => {
								if (!_that.isSmall) {
									_that.imgHeight = (data.height) / 3
									_that.imgWidth = (data.width) / 3
									_that.isSmall = !_that.isSmall
								}
							}).exec()
						})
						uni.removeStorageSync(_that.storageKey)
					}
				} catch (e) {
					// error
				}
			},
			toSignature() {
				let _that = this
				if(!_that.hasConfirmed){
					if(isEnglish(_that.userName)){
						uni.navigateTo({
							url: "../../public/signature/signature?goToOld="+true
						})
					}else{
						let signName = filterNumbers(_that.userName)
						uni.navigateTo({
							url: "../../public/signature/signature?bottomTips=" + _that.bottomTips + '&userName=' + signName
						})
					}
				}
			},
			// @param 
			// 	   fileCode busCode
			toShow(item,formCode){
				let _that = this
				if(_that.type == 'absentHours'){
					if(item.code == 'HRS1239'){
						uni.navigateTo({
							url:item.url+'?title='+item.title+'&code='+item.code+'&absentTime='+_that.absentTime+'&absentDate='+_that.absentDate
						})
					}else{
						uni.navigateTo({
							url:item.url+'?title='+item.title+'&code='+item.code
						})
					}
					this.$refs.popup.close()
				}else{
					_that.om.getFormInfoByFileCode(item,formCode)
					this.$refs.popup.close()
				}
			},
			itemClick(type,item,fileCode,formCode){
				let _that = this
				switch (type){
					case 'leave':
					 _that.type = type
						_that.formCode = item.formCode
						_that.toShow(item.code,item.formCode)
					break;
					case 'outer':
						_that.type = type
						_that.formCode = item.formCode
						_that.toShow(item.code,item.formCode)
					break;
					case 'add' :
						_that.type = type
						_that.toShow(item.fileCode,item.formCode)
					break;
					case 'absentHours':
						_that.type = type
						_that.absentDate = item.date
						_that.absentTime = fileCode
						if(formCode == "AStart"){
							if(item.isstartA){
								_that.popupList = _that.data.repairStartAbsentForms
							}else{
								_that.popupList = _that.data.repairAbsentForms
							}
						}else if(formCode == "AEnd"){
							if(item.isendA){
								_that.popupList = _that.data.repairEndAbsentForms
							}else{
								_that.popupList = _that.data.repairAbsentForms
							}
						}else if(formCode == "BStart"){
							if(item.isstartB){
								_that.popupList = _that.data.repairStartAbsentForms
							}else{
								_that.popupList = _that.data.repairAbsentForms
							}
						}else if(formCode == "BEnd"){
							if(item.isendB){
								_that.popupList = _that.data.repairEndAbsentForms
							}else{
								_that.popupList = _that.data.repairAbsentForms
							}
						}
						this.$refs.popup.open()
					break;
					case 'addRepaired':
						_that.type = type
						_that.toShow(item.fileCode,_that.data.repairAddForm.code)
					break;
					case 'addRepair':
						_that.type = type
						if(!item.start && item.end){
							uni.navigateTo({
								url:_that.data.repairAddForm.url+'?title='+_that.data.repairAddForm.title+'&code='+_that.data.repairAddForm.code+'&absentTime='+item.stdStart+'&absentDate='+fileCode+'&addRepair='+'true'
							})
						}else if(item.start && !item.end){
							uni.navigateTo({
								url:_that.data.repairAddForm.url+'?title='+_that.data.repairAddForm.title+'&code='+_that.data.repairAddForm.code+'&absentTime='+item.stdEnd+'&absentDate='+fileCode+'&addRepair='+'true'
							})
						}else if(!item.start && !item.end){
							uni.navigateTo({
								url:_that.data.repairAddForm.url+'?title='+_that.data.repairAddForm.title+'&code='+_that.data.repairAddForm.code+'&absentTime='+item.stdStart+'&absentTime1='+item.stdEnd+'&absentDate='+fileCode+'&addRepair='+'true'
							})
						}
						
					break;
					case 'lookAdd':
						_that.type = type
						_that.toShow(item.fileCode,item.formCode)
					break;
					case 'repair':
						_that.type = type
						_that.toShow(item.fileCode,item.formCode)
					break;
					case 'lookAbsentHours':
						_that.type = type
						_that.toShow(fileCode,formCode)
					break;
				}
			},
			getAttendMonth(userId) {
				let _that = this
				_that.om.request(
					"wxAttend/getAttendMonth", 
					{
						year: this.attendYear,
						month: this.attendMonth,
						userId:userId?userId:this.sUserId
					},
					'get',
					true
				).then(res => {
					_that.data = res.value
					uni.setNavigationBarTitle({
						title:_that.data.startDate+'~'+_that.data.endDate
					})
					uni.hideLoading()
					_that.showdata = true
				})
			},
			canConfirmById(id){
				let _that = this
				_that.om.request(
					"attendConfirm/canConfirmById",
					{id:id},
					'get',
					true
				).then(res => {
					if (res.succeed) {
						_that.isShow = res.value
						if(res.value){
							_that.getAccessToken()
						}
					}
				})
			}
		},
		onLoad(options) {
			this.id = options.id
			this.attendYear = options.attendYear
			this.attendMonth = options.attendMonth
			this.sUserId = options.userId
			this.sSexCode = options.sexCode
			this.canConfirmById(options.id)
		},
		onShow() {
			uni.showLoading({
				title:'请稍等....'
			})
			setTimeout(()=>{
				this.getAttendMonth()
			},1000)
			if(this.isSign){
				this.showImage()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.workhour-cache-info-head{
		width: 100%;
		height: 105px;
	}
	v-deep.uni-collapse-cell{
		border-color:#EEEEEE;
	}
	.workhour-cache-info-user-head{
		height: 40px;
		width:40px;
	}
	.border-buttom{
		border-bottom: 1px solid #EEEEEE;
	}
	.workhour-cache-info,.workhour-cache-info-user{
		display: flex;
		background-color: white;
		// position: -webkit-sticky;
		//  position: sticky;
		//  top: var(--window-top);
		z-index: 10001;
	}
	.workhour-cache-info{
		color: white;
		height: 45px;
		justify-content: space-between;
		background-color: #5697F4;
	}
	.workhour-cache-info-user{
		justify-content: flex-start;
		height: 50px;
		border-bottom: 3px solid #EEEEEE;
		// position: -webkit-sticky;
		//  position: sticky;
		//  top: var(--window-top);
	}
	.workhour-cache-info-user-name{
		line-height: 40px;
	}
	.workhour-cache-info-user-date{
		line-height: 40px;
	}
	.collapse-item-info{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.collapse-item-info-button{
		white-space: nowrap;
		border-left: 1px solid #EEEEEE ;
		color: #5697F4;
	}
	.popup-item{
		height:50px;
		background-color: #FFFF;
		font-size: 16px;
		text-align: center;
		border-bottom: 1px solid #EEEEEE;
		display: flex;
		justify-content: space-between;
	}
	.popup-cotent{
		width: 300px;
		background-color: white;
		border-radius: 10px;
	}
	.popup-tip{
		font-size: 10px;
		color:#b0b0b0 ;
	}
</style>
